<template>
  <div class="app" ref="appContainer">
    <!-- Carousel Section -->
    <section class="section carousel-section">
      <div class="carousel">
        <div class="carousel-inner">
          <div
            v-for="(image, index) in carouselImages"
            :key="'carousel-item-' + index"
            :class="['carousel-item', { active: currentSlide === index }]"
            :style="{ backgroundImage: `url(${image})` }"
          >
            <div class="carousel-caption">
              <h3>{{ captions[index].title }}</h3>
              <p>{{ captions[index].description }}</p>
              <button @click="scrollToSection(index)" class="details-button">
                详情
              </button>
            </div>
          </div>
        </div>

        <!-- Carousel Indicators as Dots -->
        <div class="carousel-indicators">
          <span
            v-for="(image, index) in carouselImages"
            :key="index"
            :class="['indicator', { active: currentSlide === index }]"
            @click="goToSlide(index)"
            aria-label="Slide Indicator"
          ></span>
        </div>
      </div>
    </section>

    <!-- Feature Sections -->
    <!-- 模块1 -->
    <section class="section container" ref="section1">
      <div class="module-wrapper">
        <div class="left-module fade-in">
          <div class="feature">
            <div
              class="text-container"
              :style="{ backgroundImage: `url(${greenBg1})` }"
            >
              <div class="part-title">
                <span class="left-arrow">←</span>
                <span class="title-text">铜镜鉴古</span>
                <span class="right-arrow">→</span>
              </div>
              <div class="image-text">
                漫步于中华千年历史，青铜器不仅是古文明的瑰宝，更承载着无尽的文化内涵。通过“青铜鉴定”，您可以上传古青铜器图片，利用先进的目标检测算法，精准检测立耳、云雷纹等细腻特征；借助“分类断代”，深度学习模型将为您揭示青铜器的类别与时代，带您穿越时光，领略古韵之美。
              </div>
              <div class="button-box">
                <div class="button-group">
                  <button
                    @click="checkLoginAndExecute(showFeatureAnalysis)"
                    class="animated-button"
                  >
                    青铜鉴定
                  </button>
                  <button
                    @click="checkLoginAndExecute(showInscriptionRecognition)"
                    class="animated-button"
                  >
                    分类断代
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="image-container right-align">
          <img :src="m1" alt="装饰图像1" class="decorative-image" />
        </div>
      </div>
    </section>

    <!-- 模块2 -->
    <section class="section container2" ref="section2">
      <div class="module-wrapper">
        <div class="image-container left-align">
          <img :src="m4" alt="装饰图像2" class="decorative-image" />
        </div>
        <div class="right-module fade-in">
          <div class="feature">
            <div
              class="text-container"
              :style="{ backgroundImage: `url(${greenBg2})` }"
            >
              <div class="part-title">
                <span class="left-arrow">←</span>
                <span class="title-text">青铜宝典</span>
                <span class="right-arrow">→</span>
              </div>
              <div class="image-text">
                “青铜图鉴”汇聚了丰富的古青铜器数据，超过10,956条详实记录，涵盖图片、类别、年代、发掘地点与收藏地等信息。更有“地图寻宝”功能，实时标注全国各地古青铜博物馆与遗址，让您在地图上轻松探寻历史的足迹，开启一段文化寻宝之旅。
              </div>
              <div class="button-box">
                <div class="button-group">
                  <button
                    @click="checkLoginAndExecute(showEncyclopedia)"
                    class="animated-button"
                  >
                    青铜图鉴
                  </button>
                  <button
                    @click="checkLoginAndExecute(showTreasureMap)"
                    class="animated-button"
                  >
                    地图寻宝
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 模块3 -->
    <section class="section container3" ref="section3">
      <div class="module-wrapper">
        <div class="left-module fade-in">
          <div class="feature">
            <div
              class="text-container"
              :style="{ backgroundImage: `url(${greenBg3})` }"
            >
              <div class="part-title">
                <span class="left-arrow">←</span>
                <span class="title-text">深入青铜</span>
                <span class="right-arrow">→</span>
              </div>
              <div class="image-text">
                “学习指南”将引领您步入青铜器的世界，从历史简介到器物类别，再到不同年代的特征花纹和典型代表，层层揭示这段辉煌文明的神秘面纱。而在“知识问答”环节，您可以通过设计精妙的题目进行自我检验，在趣味中巩固所学，不断提升鉴赏力与记忆深度。
              </div>
              <div class="button-box">
                <div class="button-group">
                  <button
                    @click="checkLoginAndExecute(showChallenge)"
                    class="animated-button"
                  >
                    学习指南
                  </button>
                  <button
                    @click="checkLoginAndExecute(showInscriptionIdentification)"
                    class="animated-button"
                  >
                    知识问答
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="image-container right-align">
          <img :src="m9" alt="装饰图像3" class="decorative-image" />
        </div>
      </div>
    </section>

    <!-- 模块4 -->
    <section class="section container4" ref="section4">
      <div class="module-wrapper">
        <div class="image-container left-align">
          <img :src="m8" alt="装饰图像4" class="decorative-image" />
        </div>
        <div class="right-module fade-in">
          <div class="feature">
            <div
              class="text-container"
              :style="{ backgroundImage: `url(${greenBg4})` }"
            >
              <div class="part-title">
                <span class="left-arrow">←</span>
                <span class="title-text">三维重建</span>
                <span class="right-arrow">→</span>
              </div>
              <div class="image-text">
                体验科技与艺术的完美融合。“模型展示”呈现了通过NeRF技术重建的精美三维青铜器模型，栩栩如生；“多图建模”功能让您仅需上传一段视频，即可轻松生成三维模型，开启您的创作之旅。让每一件青铜器在虚拟世界中焕发新生。
              </div>
              <div class="button-box">
                <div class="button-group">
                  <button
                    @click="checkLoginAndExecute(showRestoration)"
                    class="animated-button"
                  >
                    模型展示
                  </button>
                  <button
                    @click="checkLoginAndExecute(showMultiImageModeling)"
                    class="animated-button"
                  >
                    多图建模
                  </button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 查看更多，竖向展示 -->
    <div class="see-more" v-if="!isLastSection" @click="scrollToNext">
      <span>查看更多</span>
      <i class="arrow-down"></i>
    </div>

    <!-- 自定义提示框 -->
    <transition name="fade">
      <div v-if="showAlert" class="custom-alert-overlay">
        <div class="custom-alert">
          <button @click="closeAlert" class="alert-close-button">
            &times;
          </button>
          <div class="alert-content">
            <i class="fas fa-exclamation-circle alert-icon"></i>
            <p>{{ alertMessage }}</p>
          </div>
          <div class="alert-buttons">
            <button @click="handleRegister" class="alert-button register">
              立即注册
            </button>
            <button @click="handleLogin" class="alert-button login">
              立即登录
            </button>
          </div>
        </div>
      </div>
    </transition>

    <!-- 注册模态框 -->
    <transition name="fade">
      <div
        v-if="showRegistrationModal"
        class="modal-overlay"
        @click.self="closeRegistrationModal"
      >
        <div class="modal">
          <button @click="closeRegistrationModal" class="close-button">
            &times;
          </button>
          <div class="modal-header">
            <h2>注册</h2>
          </div>
          <div class="modal-body">
            <form @submit.prevent="registerUser" class="modal-form">
              <div class="form-group">
                <label for="username">用户名：</label>
                <input
                  type="text"
                  id="username"
                  v-model="username"
                  required
                  placeholder="请输入用户名"
                />
              </div>
              <div class="form-group">
                <label for="password">密码：</label>
                <input
                  type="password"
                  id="password"
                  v-model="password"
                  required
                  placeholder="请输入密码"
                />
              </div>
              <div class="form-group">
                <label for="captcha">验证码：</label>
                <input
                  type="text"
                  id="captcha"
                  v-model="captcha"
                  required
                  placeholder="请输入验证码"
                />
                <img
                  :src="captchaImageUrl"
                  alt="验证码"
                  @click="refreshCaptcha"
                  class="captcha-image"
                />
              </div>
              <button type="submit" class="submit-button">注册</button>
            </form>
          </div>
        </div>
      </div>
    </transition>

    <!-- 登录模态框 -->
    <transition name="fade">
      <div
        v-if="showLoginModal"
        class="modal-overlay"
        @click.self="closeLoginModal"
      >
        <div class="modal">
          <button @click="closeLoginModal" class="close-button">&times;</button>
          <div class="modal-header">
            <h2>登录</h2>
          </div>
          <div class="modal-body">
            <form @submit.prevent="loginUser" class="modal-form">
              <div class="form-group">
                <label for="login-username">用户名：</label>
                <input
                  type="text"
                  id="login-username"
                  v-model="username"
                  required
                  placeholder="请输入用户名"
                />
              </div>
              <div class="form-group">
                <label for="login-password">密码：</label>
                <input
                  type="password"
                  id="login-password"
                  v-model="password"
                  required
                  placeholder="请输入密码"
                />
              </div>
              <div class="form-group">
                <label for="captcha">验证码：</label>
                <input
                  type="text"
                  id="captcha"
                  v-model="captcha"
                  required
                  placeholder="请输入验证码"
                />
                <img
                  :src="captchaImageUrl"
                  alt="验证码"
                  @click="refreshCaptcha"
                  class="captcha-image"
                />
              </div>
              <button type="submit" class="submit-button">登录</button>
            </form>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { ref, onMounted, onBeforeUnmount, nextTick, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import bronzeMirror from "@/assets/m7.jpg";
import bronzeCodex from "@/assets/m5.jpg";
import challenge from "@/assets/m3.jpg";
import restoration3D from "@/assets/m15.jpg";
import m1 from "@/assets/m12.jpg";
import m4 from "@/assets/m4.jpg";
import m9 from "@/assets/m9.jpg";
import m8 from "@/assets/m8.jpg";
import greenBg1 from "@/assets/green_bg_01.jpg";
import greenBg2 from "@/assets/green_bg_02.jpg";
import greenBg3 from "@/assets/green_bg_03.jpg";
import greenBg4 from "@/assets/green_bg_04.jpg";
import axios from "axios";
import { BASE_URL } from "@/config.js";
export default {
  name: "Home",
  props: {
    isLoggedIn: {
      type: Boolean,
      default: false,
    },
  },
  setup(props, { emit }) {
    const router = useRouter();
    const route = useRoute();
    // 定义 app 容器的 ref
    const appContainer = ref(null);

    // 添加提示框相关的响应式变量
    const showAlert = ref(false);
    const alertMessage = ref("");

    // 提示框相关方法
    const showCustomAlert = (message) => {
      alertMessage.value = message;
      showAlert.value = true;
    };

    const closeAlert = () => {
      showAlert.value = false;
    };

    const handleRegister = () => {
      showAlert.value = false;
      openRegistrationModal();
    };

    const handleLogin = () => {
      showAlert.value = false;
      openLoginModal();
    };

    // 轮播图数据
    const carouselImages = ref([
      bronzeMirror, // 铜镜鉴古
      bronzeCodex, // 青铜宝典
      challenge, // 鉴识挑战
      restoration3D, // 三维重建
    ]);

    const captions = ref([
      {
        title: "铜镜鉴古",
        description: "了解青铜器的历史与文化，通过先进算法揭示古物之美",
      },
      {
        title: "青铜宝典",
        description: "探索海量古青铜数据，开启一段文化寻宝之旅",
      },
      {
        title: "深入青铜",
        description: "丰富青铜器的知识，成为真正的青铜鉴赏大师",
      },
      {
        title: "三维重建",
        description: "体验科技与艺术的融合，重现青铜器的三维魅力",
      },
    ]);

    const currentSlide = ref(0);
    const intervalId = ref(null);
    const totalSlides = carouselImages.value.length;

    // 轮播图切换方法
    const nextSlide = () => {
      currentSlide.value = (currentSlide.value + 1) % totalSlides;
    };

    const goToSlide = (index) => {
      currentSlide.value = index;
    };

    const startCarousel = () => {
      if (intervalId.value) return;
      intervalId.value = setInterval(nextSlide, 4000);
    };

    const stopCarousel = () => {
      if (intervalId.value) {
        clearInterval(intervalId.value);
        intervalId.value = null;
      }
    };

    // 查看更多按钮滚动到下一个模块
    const scrollToNext = () => {
      const currentVisible = document.querySelector(".section.visible");
      if (currentVisible) {
        const nextSection = currentVisible.nextElementSibling;
        if (nextSection && nextSection.classList.contains("section")) {
          nextSection.scrollIntoView({ behavior: "smooth" });
        }
      }
    };

    onMounted(() => {
      startCarousel();
      setupIntersectionObserver();

      // Scroll to section if scrollToSection is present
      if (route.query.scrollToSection !== undefined) {
        scrollToSection(Number(route.query.scrollToSection));
      }

      // 检查URL参数是否需要显示注册或登录模态框
      const { showRegistration, showLogin } = route.query;
      if (showRegistration) {
        openRegistrationModal();
      } else if (showLogin) {
        openLoginModal();
      }
    });

    // Watch for changes in scrollToSection
    watch(
      () => route.query.scrollToSection,
      (newVal) => {
        if (newVal !== undefined) {
          scrollToSection(Number(newVal));
        }
      }
    );

    onBeforeUnmount(() => {
      stopCarousel();
      if (observer.value) observer.value.disconnect();
    });

    // 修改登录检查方法
    const checkLoginAndExecute = (func) => {
      if (props.isLoggedIn) {
        func();
      } else {
        showCustomAlert("请先注册或登录以使用此功能");
      }
    };

    // 跳转到不同路由的方法
    const showFeatureAnalysis = () => {
      router.push({ name: "BronzeMirror", query: { fromSection: 0 } });
    };

    const showInscriptionRecognition = () => {
      router.push({ name: "BronzeClassification", query: { fromSection: 0 } });
    };

    const showEncyclopedia = () => {
      router.push({ name: "BronzeCodex", query: { fromSection: 1 } });
    };

    const showTreasureMap = () => {
      router.push({ name: "Map", query: { fromSection: 1 } });
    };

    const showChallenge = () => {
      router.push({ name: "BronzeGuide", query: { fromSection: 2 } });
    };

    const showInscriptionIdentification = () => {
      router.push({ name: "RecogChallenge", query: { fromSection: 2 } });
    };

    const showRestoration = () => {
      router.push({ name: "BronzeRestoration", query: { fromSection: 3 } });
    };

    const showMultiImageModeling = () => {
      router.push({ name: "Nerf", query: { fromSection: 3 } });
    };

    // IntersectionObserver 设置
    const observedSections = ref([]);
    const observer = ref(null);

    // 定义判断是否是最后一个模块的变量
    const isLastSection = ref(false);

    // 在IntersectionObserver或其他逻辑中检测是否到达最后一个模块
    const setupIntersectionObserver = () => {
      nextTick(() => {
        observedSections.value = Array.from(
          document.querySelectorAll(".section")
        );
        const options = {
          root: appContainer.value,
          rootMargin: "0px",
          threshold: 0.1,
        };

        observer.value = new IntersectionObserver((entries) => {
          entries.forEach((entry) => {
            if (entry.isIntersecting) {
              entry.target.classList.add("visible");

              // 如果可见的元素是最后一个模块，隐藏“查看更多”按钮
              if (entry.target === section4.value) {
                isLastSection.value = true;
              } else {
                isLastSection.value = false;
              }
            } else {
              entry.target.classList.remove("visible");
            }
          });
        }, options);

        observedSections.value.forEach((section) => {
          observer.value.observe(section);
        });
      });
    };

    // 定义各模块的 ref
    const section1 = ref(null);
    const section2 = ref(null);
    const section3 = ref(null);
    const section4 = ref(null);

    // 滚动到指定模块的方法
    const scrollToSection = (index) => {
      const sectionRefs = [section1, section2, section3, section4];
      const section = sectionRefs[index];
      if (section && section.value) {
        section.value.scrollIntoView({ behavior: "smooth" });
        console.log(`Scrolling to section index: ${index}`);
      } else {
        console.error(`无法找到目标模块，索引: ${index}`);
      }
    };

    // 添加注册和登录相关的响应式变量
    const showRegistrationModal = ref(false);
    const showLoginModal = ref(false);
    const username = ref("");
    const password = ref("");
    const captcha = ref("");
    const captchaImageUrl = ref("");

    // 刷新验证码
    const refreshCaptcha = async () => {
      try {
        const response = await axios.get(
          "https://www.lvjieshouji.cn:555/captcha",
          {
            responseType: "blob",
            withCredentials: true,
          }
        );
        const url = URL.createObjectURL(response.data);
        captchaImageUrl.value = url;
      } catch (error) {
        console.error("刷新验证码失败:", error);
        captchaImageUrl.value = null;
      }
    };

    // 注册用户
    const registerUser = async () => {
      const response = await axios.get(
        "https://www.lvjieshouji.cn:555/verify_captcha",
        {
          params: {
            captcha: captcha.value.trim().toUpperCase(),
          },
          withCredentials: true,
        }
      );

      if (response.data.success) {
        try {
          const response = await axios.post(`${BASE_URL}/api/register`, {
            username: username.value,
            password: password.value,
          });
          if (response.data.success) {
            emit("update:isLoggedIn", true);
            alert("注册成功！");
            showRegistrationModal.value = false;
            resetForm();
          } else {
            alert("注册失败：" + response.data.message);
          }
        } catch (error) {
          console.error("注册错误", error);
          alert("注册出错，请稍后再试");
        }
      } else {
        alert("验证码错误");
        refreshCaptcha();
      }
    };

    // 用户登录
    const loginUser = async () => {
      const response = await axios.get(
        "https://www.lvjieshouji.cn:555/verify_captcha",
        {
          params: {
            captcha: captcha.value.trim().toUpperCase(),
          },
          withCredentials: true,
        }
      );

      if (response.data.success) {
        try {
          const response = await axios.post(`${BASE_URL}/api/login`, {
            username: username.value,
            password: password.value,
          });
          if (response.data.success) {
            emit("update:isLoggedIn", true);
            alert("登录成功！");
            showLoginModal.value = false;
            resetForm();
          } else {
            alert("登录失败：" + response.data.message);
          }
        } catch (error) {
          console.error("登录错误", error);
          alert("登录出错，请稍后再试");
        }
      } else {
        alert("验证码错误");
        refreshCaptcha();
      }
    };

    // 重置表单
    const resetForm = () => {
      username.value = "";
      password.value = "";
      captcha.value = "";
    };

    // 打开注册模态框
    const openRegistrationModal = () => {
      showRegistrationModal.value = true;
      refreshCaptcha();
    };

    // 打开登录模态框
    const openLoginModal = () => {
      showLoginModal.value = true;
      refreshCaptcha();
    };

    // 关闭注册模态框
    const closeRegistrationModal = () => {
      showRegistrationModal.value = false;
      resetForm();
    };

    // 关闭登录模态框
    const closeLoginModal = () => {
      showLoginModal.value = false;
      resetForm();
    };

    return {
      carouselImages,
      captions,
      currentSlide,
      goToSlide,
      startCarousel,
      stopCarousel,
      checkLoginAndExecute,
      showFeatureAnalysis,
      showInscriptionRecognition,
      showEncyclopedia,
      showTreasureMap,
      showChallenge,
      showInscriptionIdentification,
      showRestoration,
      showMultiImageModeling,
      scrollToNext,
      scrollToSection,
      section1,
      section2,
      section3,
      section4,
      appContainer,
      m1,
      m4,
      m9,
      m8,
      greenBg1,
      greenBg2,
      greenBg3,
      greenBg4,
      isLastSection,
      showAlert,
      alertMessage,
      closeAlert,
      handleRegister,
      handleLogin,
      showCustomAlert,
      showRegistrationModal,
      showLoginModal,
      username,
      password,
      captcha,
      captchaImageUrl,
      registerUser,
      loginUser,
      openRegistrationModal,
      openLoginModal,
      closeRegistrationModal,
      closeLoginModal,
      refreshCaptcha,
    };
  },
};
</script>

<style scoped>
@import url("https://fonts.googleapis.com/css2?family=Hanalei+Fill&display=swap");

/* 全局重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body,
#app,
.app {
  height: 100%;
  width: 100%;
}

.app {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100vh;
  position: relative;
  scrollbar-width: none; /* Firefox */
}

.app::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.section {
  height: 100vh;
  scroll-snap-align: start;
  position: relative;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease-out, transform 1s ease-out;
}

.section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Carousel Styles */
.carousel-section .carousel {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
  margin: 0;
  border-radius: 0;
}

.carousel-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
}

.carousel-item.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
  animation: zoomInFadeOut 4s linear forwards;
}

@keyframes zoomInFadeOut {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  85% {
    transform: scale(1.1);
    opacity: 1;
  }
  95% {
    transform: scale(1.1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

.carousel-caption {
  position: absolute;
  bottom: 20%;
  left: 10%;
  color: #fff;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
  font-family: "Hanalei Fill", cursive;
}

.carousel-caption h3 {
  font-size: 4vw;
  margin-bottom: 10px;
}

.carousel-caption p {
  font-size: 2vw;
  max-width: 600px;
}

.details-button {
  margin-top: 20px;
  padding: 10px 20px;
  border: 2px solid white;
  background-color: transparent;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  font-size: 16px;
  border-radius: 10px;
}

.details-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #121312;
}

.details-button:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* 模块样式 */
.container,
.container2,
.container3,
.container4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2vw 8vw;
  height: 100%;
  background-position: center;
}

.container,
.container3 {
  flex-direction: row;
}

.container2,
.container4 {
  flex-direction: row-reverse;
}

.module-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.left-module,
.right-module {
  display: flex;
  flex-direction: column;
  max-width: 50%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  align-items: flex-start;
}

.container2 .right-module,
.container4 .right-module {
  align-items: flex-end;
}

.left-module,
.right-module,
.image-container {
  flex: 1;
}

.feature {
  width: 100%;
  position: center;
}

/* 装饰图片样式 */
.decorative-image {
  border-radius: 25px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  position: relative;
  max-width: 82%;
  height: auto;
}

/* 对齐方式 */
.image-container.left-align .decorative-image {
  margin-left: -2vw;
}

.image-container.right-align .decorative-image {
  margin-left: 8vw;
}

/* 文字样式 */
.part-title {
  font-family: "Hanalei Fill", cursive, SourceHanSerifCN-Heavy,
    SourceHanSerifCN-Heavy-MAX, serif;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  width: 100%;
}

.part-title .left-arrow,
.part-title .right-arrow {
  font-size: 24px;
  color: #fff0bd;
  margin: 0 10px;
}

.part-title .title-text {
  font-weight: 900;
  font-size: 2.5vw;
  line-height: 1.2;
  letter-spacing: 2px;
  color: #fff0bd;
  display: block;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

/* Text container styles */
.text-container {
  background-size: cover;
  background-position: center;
  border-radius: 25px;
  padding: 30px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  z-index: 2;
  width: 90%;
}

/* Image text styles */
.image-text {
  margin-bottom: 20px;
  color: white;
  font-size: 1.2vw;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  width: 100%;
  line-height: 1.7;
}

/* Button styles */
.button-box {
  padding: 10px 0;
  display: flex;
  justify-content: flex-start;
  width: 100%;
}

.container2 .button-box,
.container4 .button-box {
  justify-content: flex-end;
}

.button-group {
  display: flex;
  justify-content: space-between;
  width: 50%;
  margin-right: 0; /* 移除或设置为0 */
}

.animated-button {
  margin: 0 5px;
  padding: 10px 20px;
  border: 2px solid white;
  background-color: transparent;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  font-size: 1vw;
  line-height: 1.5;
  text-align: center;
  border-radius: 10px;
}

.animated-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: rgb(18, 19, 18);
}

.animated-button:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* 右侧"查看更多" */
.see-more {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 1000;
}

.see-more span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: #fff0bd;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
  font-family: "Hanalei Fill", cursive;
  animation: fadeIn 2s infinite;
}

.arrow-down {
  width: 0;
  height: 0;
  border-top: 10px solid #fff0bd;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  /* animation: arrowBounce 2s infinite; */
}

/* 动画效果 */
/* @keyframes arrowBounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(5px); }
  60% { transform: translateY(3px); }
} */

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* 响应式设计 */
@media screen and (max-width: 1440px) {
  .container,
  .container2,
  .container3,
  .container4 {
    padding: 2vw 6vw;
  }

  .decorative-image {
    transform: scale(1.3);
  }
}

@media screen and (max-width: 1024px) {
  .container,
  .container2,
  .container3,
  .container4 {
    padding: 2vw 4vw;
  }

  .decorative-image {
    transform: scale(1.2);
  }

  .carousel-caption h3 {
    font-size: 5vw;
  }

  .carousel-caption p {
    font-size: 2.5vw;
  }

  .part-title .title-text {
    font-size: 3vw;
  }

  .image-text {
    font-size: 1.5vw;
  }

  .animated-button {
    font-size: 1.2vw;
  }
}

@media screen and (max-width: 768px) {
  .container,
  .container2,
  .container3,
  .container4 {
    flex-direction: column;
    padding: 2vw;
    height: auto;
  }

  .left-module,
  .right-module {
    max-width: 100%;
    margin-bottom: 20px;
    align-items: center;
  }

  .image-container {
    justify-content: center;
    padding: 0;
    margin-bottom: 20px;
  }

  .decorative-image {
    width: 80%;
    max-width: 300px;
    margin: 0 auto;
    transform: scale(1);
  }

  .text-container {
    width: 100%;
    padding: 15px;
    overflow-y: auto;
  }

  .button-group {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  .animated-button {
    width: 80%;
    margin: 5px 0;
    font-size: 2vw;
  }

  .carousel-caption h3 {
    font-size: 6vw;
  }

  .carousel-caption p {
    font-size: 3vw;
    max-width: 90%;
  }

  .part-title .title-text {
    font-size: 4vw;
  }

  .image-text {
    font-size: 2vw;
  }
}

@media screen and (max-width: 480px) {
  .carousel-caption h3 {
    font-size: 8vw;
  }

  .carousel-caption p {
    font-size: 4vw;
    max-width: 95%;
  }

  .part-title .title-text {
    font-size: 6vw;
  }

  .image-text {
    font-size: 3.5vw;
  }

  .see-more span {
    font-size: 16px;
  }

  .decorative-image {
    display: none;
  }

  .text-container {
    width: 100%;
    padding: 15px;
    overflow-y: auto;
    text-align: center;
  }

  .part-title,
  .image-text,
  .button-box {
    text-align: center;
  }

  .button-group {
    flex-direction: column;
    align-items: center;
    width: 100%;
  }

  .animated-button {
    width: 80%;
    margin: 5px 0;
    font-size: 3.5vw;
  }
}

/* 自定义提示框样式 */
.custom-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.alert-close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  color: #f3d68b;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  padding: 0;
  line-height: 1;
}

.alert-close-button:hover {
  background: rgba(243, 214, 139, 0.1);
  transform: rotate(90deg);
}

.custom-alert {
  background: #2e2e2e;
  border-radius: 15px;
  padding: 25px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border: 1px solid #f3d68b;
  animation: alertAppear 0.3s ease;
  position: relative;
}

.alert-content {
  display: flex;
  align-items: center;
  margin-bottom: 25px;
  color: #f3d68b;
}

.alert-buttons {
  display: flex;
  gap: 15px;
  justify-content: space-between;
}

.alert-icon {
  font-size: 24px;
  margin-right: 15px;
  color: #f3d68b;
}

.alert-content p {
  font-size: 16px;
  margin: 0;
  line-height: 1.5;
}

.alert-button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.alert-button.register {
  background: linear-gradient(45deg, #8b5e3c, #5d3b1e);
}

.alert-button.login {
  background: linear-gradient(45deg, #d4af37, #b8860b);
}

.alert-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  opacity: 0.9;
}

.alert-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes alertAppear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 添加模态框相关样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 8, 8, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1002;
}

.modal {
  position: relative;
  background: #1e1e1e;
  padding: 30px;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  color: #f3d68b;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-header h2 {
  margin-top: 0;
  font-family: "KaiTi", "SimSun", "STSong", serif;
  text-align: center;
}

.modal-body {
  margin-top: 20px;
  width: 100%;
}

.modal-form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.form-group {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  width: 100%;
}

.form-group label {
  width: 100px;
  margin-right: 10px;
  text-align: right;
  font-size: 16px;
}

.form-group input {
  flex-grow: 1;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #555;
  background: #2e2e2e;
  color: #f3d68b;
  font-size: 16px;
  box-sizing: border-box;
}

.captcha-image {
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.3s ease;
  margin-left: 10px;
}

.captcha-image:hover {
  opacity: 0.8;
}

.submit-button {
  background: linear-gradient(45deg, #8b5e3c, #5d3b1e);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  padding: 10px 20px;
  font-size: 17px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  margin-top: 20px;
}

.submit-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #f3d68b;
  transition: color 0.3s ease;
}

.close-button:hover {
  color: #e74c3c;
}

/* 添加过渡动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
